// pages/list/list.js
var app = getApp();
Page({
  data: {
    userInfo: {},
    scroll:true,
    height:'530',
    openid: '',
    mask: '',
    keyword: '',
    tactive:'',
    nactive:'',
    oactive:'',
    aactive:'',
    type_name:'选择分类',
    near_name:'附近',
    order_name:'排序',
    gps: '重庆',
    list: [{ url: '../shop/shop', logo: '../img/ll1.png', name: '阿利与艾德炭烤麻里牛排海鲜自助烤肉（煌华新纪元购', place: '沙坪坝观音桥', distance: '256m', label: '烧烤烤肉', song: '1', quan: '38元抵100元代金券', pin: '青椒肉丝炒饭10元短标', tuan: '4人套餐48.8元, 6人餐228元短标, 4人餐188元（原价264元）短标, 8人餐短标,', mian: '冰柠檬水免费赠饮一杯,  回锅肉炒饭一份短标,   ' }, { url: '../shop/shop', logo: '../img/ll2.png', name: '阿利与艾德炭烤麻里牛排海鲜自助烤肉（煌华新纪元购', place: '沙坪坝观音桥', distance: '256m', label: '烧烤烤肉', song: '0', quan: '38元抵100元代金券' }, { url: '../shop/shop', logo: '../img/ll1.png', name: '阿利与艾德炭烤麻里牛排海鲜自助烤肉（煌华新纪元购', place: '沙坪坝观音桥', distance: '256m', label: '烧烤烤肉', song: '1', quan: '38元抵100元代金券', pin: '青椒肉丝炒饭10元短标', mian: '冰柠檬水免费赠饮一杯,  回锅肉炒饭一份短标,   ' }],
    type: ['洗浴汗蒸', '足疗按摩', 'KTV影院', '密室逃脱', '酒吧', '电玩游戏VR', '运动健身', '私人影院', 'DIY手工坊', '网吧网咖', '茶馆', '轰趴馆', '桌游棋牌', '桌游棋牌', '真人CS', '演出赛事', '演出赛事', '丽人宠物', '文化艺术', '采摘农家'],
    near: ['渝中', '渝北', '江北', '大渡口', '九龙坡', '北碚', '巴南', '渝北', '沙坪坝', '南岸'],
    area: ['观音桥', '解放碑', '大坪', '两路口', '上清寺', '朝天门', '化龙桥', '大礼堂', '较场口', '长滨路', '总部城','时代天街'],
    order: ['距离', '价格', '团', '券', '拼', '免'],
  },
  
  



  //事件处理函数
  onShareAppMessage: function () {
    return { title: '推荐一个不错的视频直播平台', path: '/page/user?id=123' }
  },
  type:function(){
    this.setData({
      tactive: this.data.tactive == 'active' ? '' : 'active',
      aactive: '',
      nactive: '',
      oactive: ''
    })
    this.must()
  },
  near: function () {
    this.setData({
      tactive: '',
      aactive: '',
      nactive: this.data.nactive == 'active' ? '' : 'active',
      oactive: ''
    })
    this.must()
  },
  order: function () {
    this.setData({
      tactive: '',
      nactive: '',
      aactive: '',
      oactive: this.data.oactive == 'active' ? '' : 'active'
    })
    this.must()
  }, 
  area_show: function() {
    this.setData({
      aactive: 'active'
    })
    this.must()
  },
  must:function(){
    var that=this
    if (this.data.tactive == 'active' || this.data.nactive == 'active' || this.data.oactive == 'active') {
      that.setData({
        scroll: false
      })
    } else {
      that.setData({
        scroll: true
      })
    }
  },
  type_pick: function (e) {
    var that = this;
    let name = e.currentTarget.dataset.name;
    wx.redirectTo({
      url: '../list/list?type=' + name + '&&near=' + that.data.near_name + '&&order=' + that.data.order_name
    })
  },
  near_pick: function (e) {
    var that=this;
    let name = e.currentTarget.dataset.name;
    wx.redirectTo({
      url: '../list/list?type=' + that.data.type_name + '&&near=' + name + '&&order=' + that.data.order_name
    })
  },
  order_pick: function (e) {
    var that = this;
    let name = e.currentTarget.dataset.name;
    wx.redirectTo({
      url: '../list/list?type=' + that.data.type_name + '&&near=' + that.data.near_name + '&&order=' + name
    })
  },
  home:function(){ 
    wx.switchTab({
      url: '../index/index',
    })
  },
  location: function () {
    wx.navigateTo({
      url: '../gps/gps',
    })
  },
  maskshow: function () {
    this.setData({
      mask: 'active'
    })
  },
  maskhide: function () {
    this.setData({
      mask: ''
    })
  },
  toinput: function (e) {
    this.setData({
      keyword: e.detail.value
    })
  },
  serach: function () {
    wx.showToast({
      title: '搜索' + this.data.keyword,
    })
  }, 
  onLoad: function (options) {
    var that = this
      that.setData({
        type_name: options.type == 'undefined' ? '选择分类' : options.type,
        near_name: options.near == 'undefined' ? '附近' : options.near,
        order_name: options.order == 'undefined' ? '排序' : options.order
      })
      wx.getSystemInfo({
        success: function(res) {
         that.setData({
           height: res.windowHeight-59
         })
        }
      })
  },
  onReady: function () {

  }
})
